package com.wty.cmims.controller;

import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.PrescriptionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/prescription")
@Tag(name = "处方信息", description = "社区医疗信息后台管理系统api接口")
public class PrescriptionController {
    @Autowired
    private PrescriptionService prescriptionService;

    // 根据病历ID查询处方信息
    @PostMapping("/findPrescriptionByAppointmentId")
    @Operation(summary = "处方信息获取", description = "处方信息获取")
    @Parameter(name = "appointmentId",description = "预约ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> prescriptionFindByAppointmentId(@RequestParam Integer appointmentId){
        return prescriptionService.prescriptionFindByAppointmentId(appointmentId);
    }

    // 根据居民ID查询处方
    @PostMapping("/findPrescriptionByResidentId")
    @Operation(summary = "根据居民ID查询处方", description = "根据居民ID查询处方")
    @Parameter(name = "residentId",description = "居民ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<List<Map<String, Object>>> prescriptionFindByResidentId(@RequestParam Integer residentId){
        return prescriptionService.prescriptionFindByResidentId(residentId);
    }
}